home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / mike40c.arc / INT24.ASM < prev    next >
Assembly Source File  |  1986-10-24  |  3KB  |  136 lines

  1. page,132
  2. title INT24.ASM - CRITICAL ERROR PROCEDURES for MICROSOFT 'C' (4.0)
  3. ; Traps int24 critical error handler.  int24error & int24result must
  4. ; be declared in C source code.  int24error is set if an error occurs
  5. ; and int24result contains the cause.
  6. ;
  7. ;         int24result
  8. ;         Error Code           Description
  9. ;         ===========          =============
  10. ;            0                 Attempt to write on write-protected disk
  11. ;            1                 Unknown unit
  12. ;            2                 Drive not ready
  13. ;            3                 Unknown Command
  14. ;            4                 Data error (CRC)
  15. ;            5                 Bad Request structure length
  16. ;            6                 Seek error
  17. ;            7                 Unknown media type
  18. ;            8                 Sector not found
  19. ;            9                 Printer out of paper
  20. ;            A                 Write fault
  21. ;            B                 Read fault
  22. ;            C                 General failure
  23. ;
  24.  
  25. public    int24,__int24on,__int24off
  26.  
  27. DGROUP     GROUP    _DATA
  28.  
  29. _data        segment    word     public    'DATA'
  30.     extrn            _int24error:byte, _int24result:byte          ;you can find this variable in C's data segment
  31.         OldInt24Seg     dw      0
  32.         OldInt24Off     dw      0
  33.         FCBFuncs        db      14,15,21,22,27,28
  34. _data        ends
  35.  
  36. _text        segment    byte    public    'CODE'
  37.         assume    cs:_text,ds:DGROUP
  38.  
  39. int24        proc    far
  40.         push    bp
  41.         mov     bp,sp
  42.         push    bp
  43.         push    ax
  44.         mov     ax,DGROUP
  45.         mov     ds,ax
  46.         mov     es,ax
  47.         pop     ax
  48.         mov     _int24error,1
  49.         mov     sp,bp
  50.         add     sp,8
  51.         mov     ax,di
  52.         mov     _int24result,al
  53.         pop     ax
  54.         mov     cx,6
  55.         mov     di,offset FCBFuncs
  56.         repnz   scasb
  57.         jnz     not_1
  58.         mov     al,1
  59.         jmp     go_to_prog
  60.  
  61. not_1:
  62.         cmp     al,39h
  63.         mov     al,0ffh
  64.         jb      go_to_prog
  65.         mov     al,83h
  66.  
  67. go_to_prog:
  68.         pop     bx
  69.         pop     cx
  70.         pop     dx
  71.         pop     si
  72.         pop     di
  73.         mov     bp,sp
  74.         or      byte ptr [bp+0ah],1
  75.         pop     bp
  76.         pop     ds
  77.         pop     es
  78.         iret
  79. int24          endp
  80.  
  81. __int24on       proc    near ;far for large model
  82.         push    ds
  83.         push    es
  84.         push    ax
  85.         push    bx
  86.         push    dx
  87.         mov     ax,DGROUP
  88.         mov     ds,ax
  89.         mov     ax,3524h
  90.         int     21h
  91.         mov     OldInt24Seg,es
  92.         mov     OldInt24Off,bx
  93.         mov     ax,_text
  94.         mov     ds,ax
  95.         mov     dx,offset int24
  96.         mov     ax,2524h
  97.         int     21h
  98.         pop     dx
  99.         pop     bx
  100.         pop     ax
  101.         pop     es
  102.         pop     ds
  103.         ret
  104. __int24on       endp
  105.  
  106. __int24off      proc    near ;far for large model
  107.         push    ds
  108.         push    es
  109.         push    ax
  110.         push    dx
  111.         mov     ax,DGROUP
  112.         mov     ds,ax
  113.         mov     dx,OldInt24Off
  114.         mov     ds,OldInt24Seg
  115.         mov     ax,2524h
  116.         int     21h
  117.         pop     dx
  118.         pop     ax
  119.         pop     es
  120.         pop     ds
  121.         ret
  122. __int24off      endp
  123.  
  124. _text        ends
  125.     end
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.